package com.mjh.zhujianju.controller;

import com.livew.framework.interceptor.URLPermission;
import com.livew.framework.pojo.AjaxResult;
import com.livew.framework.utils.XTCurrentUser;
import com.livew.framework.utils.XTStringUtils;
import com.mjh.zhujianju.service.supervise.SupervisionService;
import com.mjh.zhujianju.util.ApiConstant;
import com.mjh.zhujianju.util.JsonResult;
import com.mjh.zhujianju.vo.supervision.StatisticsVO;
import com.mjh.zhujianju.vo.supervision.SupervisionVO;
import io.swagger.annotations.Api;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: Alex
 * @version: V1.0
 * @project: zhujianju
 * @package: com.mjh.zhujianju.controller.supervise
 * @description: description
 * @date: 2018/8/15
 * @time: 下午2:47
 */
@RestController
@RequestMapping("supervise/statistics")
@Api("2、WX->督办统计")
public class StatisticsController {
	
	@Resource
	private SupervisionService supervisionService;

    @RequestMapping(value="getStatistics/{type}",method=RequestMethod.GET)
    @ResponseBody
    public ResponseEntity<JsonResult> getStatistics(@PathVariable(name = "type")String type) {
		JsonResult result = new JsonResult();
		StatisticsVO vo = null;
		try{
			if("0".equals(type)){
				vo = new StatisticsVO();
				supervisionService.getStatistics(vo);
				//工作量/完成情况
				result.setStatus(ApiConstant.MSG_SUCCESS);
				result.setResult(vo);
			}else if("1".equals(type)){
				vo = new StatisticsVO();
				vo.setDeptId(XTCurrentUser.getCurrentUser().getDeptId());
				supervisionService.getStatistics(vo);
				//工作量/完成情况
				result.setStatus(ApiConstant.MSG_SUCCESS);
				result.setResult(vo);
			}else if("2".equals(type)){
				vo = new StatisticsVO();
				vo.setUserId(XTCurrentUser.getCurrentUserId());
				supervisionService.getStatistics(vo);
				//工作量/完成情况
				result.setStatus(ApiConstant.MSG_SUCCESS);
				result.setResult(vo);
			}else {
				result.setResult("参数错误");
				result.setStatus(ApiConstant.MSG_ERROR);
			}
		}catch (Exception e){
			result.setResult(e.getClass().getName() + ":" + e.getMessage());
			result.setStatus(ApiConstant.MSG_ERROR);
		}

    	return ResponseEntity.ok(result);
    }
    
}
